import {createRouter, createWebHashHistory } from 'vue-router';
import base from './modules/base.js'
import vol from './modules/vol.js'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

const basePath = '/'

const router = createRouter({
	history: createWebHashHistory(basePath), // 如果是根目录部署请配置为 /
	routes: [
		vol,
		...base
	]
})
router.beforeEach((to, from, next) => {
	document.title = to.meta.title;
	NProgress.start()
  to.query.openid && sessionStorage.setItem('openid', to.query.openid);
  to.query.projectId && sessionStorage.setItem('projectId', to.query.projectId);
  to.query.volunteer && sessionStorage.setItem('volunteer', to.query.volunteer);
  to.query.isScan && sessionStorage.setItem('isScan', !!to.query.isScan);
	next()
})
router.afterEach(()=>{
    NProgress.done()
})

export default router
